<template>
  <Echart height="300px" width="100%" :options="options"/>
</template>

<script>
import Echart from '@/components/Echart/index'
import resize from './mixins/resize'

export default {
  mixins: [resize],
  components: { Echart },
  props: {
    autoResize: {
      type: Boolean,
      default: true
    },
    chartData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
     options:{}
    }
  },
  watch: {
    chartData: {
      immediate: true,
      deep: true,
      handler(val) {
        this.options={
          xAxis: {
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
            boundaryGap: false,
            axisTick: {
              show: false
            }
          },
          grid: {
            left: 10,
            right: 10,
            bottom: 20,
            top: 30,
            containLabel: true
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'cross'
            },
            padding: [5, 10]
          },
          yAxis: {
            axisTick: {
              show: false
            },
            splitLine:{
              show:true,
              lineStyle:{
                color:'rgba(255,255,255,0.15)'
              }
            },
          },
          legend: {
            data: ['expected', 'actual']
          },
          series: [{
            name: 'expected', itemStyle: {
              normal: {
                color: '#FF005A',
                lineStyle: {
                  color: '#FF005A',
                  width: 2
                }
              }
            },
            smooth: true,
            type: 'line',
            data: val.expectedData,
            animationDuration: 2800,
            animationEasing: 'cubicInOut'
          },
            {
              name: 'actual',
              smooth: true,
              type: 'line',
              itemStyle: {
                normal: {
                  color: '#3888fa',
                  lineStyle: {
                    color: '#3888fa',
                    width: 2
                  },
                  areaStyle: {
                    color: '#f3f8ff'
                  }
                }
              },
              data: val.actualData,
              animationDuration: 2800,
              animationEasing: 'quadraticOut'
            }]
        }
      }
    }
  },

}
</script>
